package org.bot.plugin.web.event;

import org.bot.api.event.DataStorage;
import org.bot.api.event.EventName;
import org.bot.api.event.Events;
import org.bot.api.flow.FlowNode;
import org.bot.plugin.web.util.SelectorType;
import org.bot.plugin.web.util.WebApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@EventName("等待元素加载")
public class WebWaitForElementToLoad implements Events {

    int timeout = 60; // 超时时间（秒）

    @Autowired
    WebApi webApi;

    @Override
    public Object exec(FlowNode node, DataStorage data) {
        webApi.waitForElementToLoad(webApi.getWebDriver(node), timeout,
                SelectorType.getType(node.getSelectorType()), node.getArg());
        return null;
    }

}
